﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Twittit.Web
{
    public partial class Tag : System.Web.UI.Page
    {
        static List<Twittit.DataAccess.Twit> twitList = new List<Twittit.DataAccess.Twit>();
        protected void Page_Load(object sender, EventArgs e)
        {
            
            twitList = Twittit.Business.UserService.getInstance().getTwittsByTag(Request.QueryString["value"]);
            twittitReapeater.DataSource = twitList.Take(15);
            twittitReapeater.DataBind();
        }

        [WebMethod(EnableSession = true)]
        public static String showProfile(int id)
        {
            String result = "<div class=\"ajaxprofile\">";
            Twittit.DataAccess.User user = Twittit.Business.UserService.getInstance().getUserByID(id);
            result += "<span class=\"avatar\"><img src=" + user.getGravatarURL() + "/></span>";
            result += "<span class=\"author\">"+user.twittit+"</span>";
            result += "<span class=\"count\">Nombre de Twittits :" + Twittit.Business.UserService.getInstance().countUserPosts(user.id) + "</span>";
            result += "<span class=\"followers\">Personnes suivants ce membre: " + Twittit.Business.UserService.getInstance().countSubscribed(user.id) + "</span>";
            result += "<span class=\"following\">Personnes suivies par ce membre: " + Twittit.Business.UserService.getInstance().countSubscribers(user.id) + "</span>";
;
            result += "<span class=\"links\"><a class=\"button\" href=\"Profile.aspx?user="+user.id+"\">Voir le profil</a></span>";
            result +="</div>";
            return result;
        }
    }
}